﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace SuperStarProject
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Nhan Vien Them Qua Tang cho San Pham",
                "quatang/nv/{masanpham}",
                new { controller = "QuaTang", action = "CreateQuaTangNhanVien" }
            );
            

            routes.MapRoute(
                "DS quà PhieuMuaHangTheo UC",
                "ucdanhsachquatangtheophieumuahang/{maphieumuahang}",
                new { controller = "PhieuChonQuaTang", action = "ShowDSQuaTangTheoMaPhieuMuaHangUC" }
            );
            routes.MapRoute(
                "Error",
                "error/{mess}",
                new { controller = "Home", action = "Error" }
            );
            routes.MapRoute(
                "Thong ke",
                "thongke",
                new { controller = "Product", action = "ThongKeSanPhamMuaNhieuNhat" }
            );
            routes.MapRoute(
                "DS random product",
                "ucrandproduct",
                new { controller = "Product", action = "RandomProduct" }
            );
            routes.MapRoute(
                "DS live product",
                "uchotproduct",
                new { controller = "Product", action = "HotProduct" }
            );
            routes.MapRoute(
                "DS hot product",
                "ucliveproduct",
                new { controller = "Product", action = "SpecialProduct" }
            );
            routes.MapRoute(
                 "DS ended product",
                 "ucendproduct",
                 new { controller = "Product", action = "EndedProduct" }
             );
            routes.MapRoute(
                "Chinh sua qua",
                "chonquatang/edit/{maPhieuMuaHang}",
                new { controller = "PhieuChonQuaTang", action = "EditDSQuaTang" }
            );
            //http://server/chonquatang/KH1SP00125121990
            routes.MapRoute(
                "Chon qua",
                "chonquatang/create/{maPhieuMuaHang}",
                new { controller = "PhieuChonQuaTang", action = "CreateDSQuaTang"}
            );
            //http://server/chonquatang/KH1SP00125121990
            routes.MapRoute(
                "Liệt kê danh sách sản phẩm cho nhân viên",
                "product/nv/showall/",
                new { controller = "Product", action = "ShowAllSPNhanVien" }
            );

            //http://server/chonquatang/KH1SP00125121990
            routes.MapRoute(
                "Them san pham",
                "product/nv/create/",
                new { controller = "Product", action = "CreateSPNhanVien" }
            );
            /// http://localhost:1332/phieumuahangs/dl1/list/1
            routes.MapRoute(
                "Show All PhieuMuaHang cho Dai Ly",
                "phieumuahangs/{madaily}/list/{tinhtranggiao}",
                new { controller = "PhieuMuaHang", action = "ShowAllPhieuMuaHangDaiLy"}
            );
            /// http://server/phieumuahang/edit/KH1SP00125121990
            routes.MapRoute(
                "Edit Phieu Mua Hang",
                "phieumuahangs/edit/{maphieumuahang}",
                new { controller = "PhieuMuaHang", action = "Edit" }
            );
            /// http://server/phieumuahang/delete/KH1SP00125121990
            routes.MapRoute(
                "Delete Phieu Mua Hang",
                "phieumuahangs/delete/{maphieumuahang}",
                new { controller = "PhieuMuaHang", action = "Delete" }
            );
            /// http://server/phieumuahang/KH1SP00125121990
            routes.MapRoute(
                "View Details PhieuMuaHang",
                "phieumuahangs/{maphieumuahang}",
                new { controller = "PhieuMuaHang", action = "ViewDetails" }
            );

            routes.MapRoute(
                "Action Changestate",
                "phieumuahangs/{maphieumuahang}/{state}",
                new { controller = "PhieuMuaHang", action = "ChangeState" }
            );

            routes.MapRoute(
                "Show All PhieuMuaHang",
                "phieumuahangs",
                new { controller = "PhieuMuaHang", action = "ShowAllMyPhieuMuaHang" }
            );

            routes.MapRoute(
                "View Profile",
                "user/{accountName}",
                new { controller = "Account", action = "ViewProfile" }
            );


            routes.MapRoute(
                "View Details QuaTang",
                "quatang/{ma}",
                new { controller = "QuaTang", action = "ViewDetails" }
            );

            routes.MapRoute(
                "View Details Local",
                "producttemp/{productId}",
                new { controller = "Product", action = "ViewDetailsLocal" }
            );


            routes.MapRoute(
                "View Details",
                "product/{productId}",
                new { controller = "Product", action = "ViewDetails" }
            );


            routes.MapRoute(
                "Show All Product",
                "products",
                new { controller = "Product", action = "ShowAllProducts" }
            );


            routes.MapRoute(
                "Show All NhaCungCap",
                "nhacungcaps",
                new { controller = "NhaCungCap", action = "ShowAll" }
            );


            routes.MapRoute(
                "View Details NhaCungCap",
                "nhacungcap/{manhacungcap}",
                new { controller = "NhaCungCap", action = "ViewDetails" }
            );

            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}",                           // URL with parameters
                new { controller = "Product", action = "ShowAllProducts" }  // Parameter defaults
            );

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }
    }
}